package com.example.commen.other

fun stringisNull(str: CharSequence?): String {
    return if (str.isNullOrEmpty()) "" else str.toString()
}
fun String.EmptyOrNull(): String {
    return if (this.isNullOrEmpty()) "--" else this
}
fun integerisNull(str: Int?): Int {
    try {
        return str ?: 0
    }catch (e:Exception){
        return 0
    }

}
fun String.BlankToInt():Int{
    return if (this.isBlank()) 0 else this.toInt()
}
fun String.BlankToFloat():Float{
    return if (this.isBlank()) 0.0f else this.toFloat()
}
fun CharSequence?.getNotNulllString():String{
    return if (this.isNullOrEmpty()) "" else this.toString()
}

/**
 * 返回对象的唯一标识符
 * @param obj 需要取得唯一标识符的对象
 * @return className@hashcode 形式的唯一标识符。
 */
fun identityToString(obj: Any): String {
    return (obj.javaClass.name + "@" + Integer.toHexString(System.identityHashCode(obj)))
}